package com.example.orderflow.controller;

import java.util.List;

import com.example.orderflow.controller.base.ABaseController;
import com.example.orderflow.entity.query.RoleInfoQuery;
import com.example.orderflow.entity.po.RoleInfo;
import com.example.orderflow.entity.vo.ResponseVO;
import com.example.orderflow.service.RoleInfoService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 *  Controller
 */
@RestController("roleInfoController")
@RequestMapping("/roleInfo")
public class RoleInfoController extends ABaseController {

	@Resource
	private RoleInfoService roleInfoService;
	/**
	 * 根据条件分页查询
	 */
	@RequestMapping("/loadDataList")
	public ResponseVO loadDataList(RoleInfoQuery query){
		return getSuccessResponseVO(roleInfoService.findListByPage(query));
	}

	/**
	 * 新增
	 */
	@RequestMapping("/add")
	public ResponseVO add(RoleInfo bean) {
		roleInfoService.add(bean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增
	 */
	@RequestMapping("/addBatch")
	public ResponseVO addBatch(@RequestBody List<RoleInfo> listBean) {
		roleInfoService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增/修改
	 */
	@RequestMapping("/addOrUpdateBatch")
	public ResponseVO addOrUpdateBatch(@RequestBody List<RoleInfo> listBean) {
		roleInfoService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据RoleName查询对象
	 */
	@RequestMapping("/getRoleInfoByRoleName")
	public ResponseVO getRoleInfoByRoleName(String roleName) {
		return getSuccessResponseVO(roleInfoService.getRoleInfoByRoleName(roleName));
	}

	/**
	 * 根据RoleName修改对象
	 */
	@RequestMapping("/updateRoleInfoByRoleName")
	public ResponseVO updateRoleInfoByRoleName(RoleInfo bean,String roleName) {
		roleInfoService.updateRoleInfoByRoleName(bean,roleName);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据RoleName删除
	 */
	@RequestMapping("/deleteRoleInfoByRoleName")
	public ResponseVO deleteRoleInfoByRoleName(String roleName) {
		roleInfoService.deleteRoleInfoByRoleName(roleName);
		return getSuccessResponseVO(null);
	}
}